package com.cm.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cm.domain.Question;
import com.cm.service.QuestionServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/question")
public class QuestionController{

    @Autowired
    private QuestionServiceImpl questionService;

    @GetMapping("/get")
    public Map<String,Object> getAnswer(String question){
        LambdaQueryWrapper<Question> condition = new LambdaQueryWrapper();
        condition.like(Question::getQuestion,question);
        List<Question> list = questionService.list(condition);
        HashMap<String, Object> result = new HashMap<>();
        result.put("code",200);
        result.put("data",list);
        return result;
    }

}
